﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Text;
using Utils;

public partial class order_chinabank_Receive : BasePage
{

    protected string remark1;
    protected string remark2;
    protected string status_msg;
    protected string str;
    protected string v_amount;
    protected string v_md5str;
    protected string v_moneytype;
    protected string v_oid;
    protected string v_pmode;
    protected string v_pstatus;
    protected string v_pstring;

    // Methods
    private void log(string result)
    {
        object obj4;
        string path = base.Server.MapPath("~/chinabanklog");
        object obj2 = new object();
        object obj3 = new object();
        lock ((obj4 = obj2))
        {
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
        }
        string str2 = base.Server.MapPath("~/chinabanklog/" + DateTime.Now.ToString("yyyyMMdd") + ".config");
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < base.Request.Form.Count; i++)
        {
            builder.Append("&" + base.Request.Form.Keys[i] + "=" + base.Request.Form[i]);
        }
        lock ((obj4 = obj3))
        {
            File.AppendAllText(str2, builder.ToString() + result);
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        string str = base.ASSystemArr["chinabanksec"];
        this.v_oid = base.Request["v_oid"];
        this.v_pstatus = base.Request["v_pstatus"];
        this.v_pstring = base.Request["v_pstring"];
        this.v_pmode = base.Request["v_pmode"];
        this.v_md5str = base.Request["v_md5str"];
        this.v_amount = base.Request["v_amount"];
        this.v_moneytype = base.Request["v_moneytype"];
        this.remark1 = base.Request["remark1"];
        this.remark2 = base.Request["remark2"];
        string str2 = Helper.MD5(this.v_oid + this.v_pstatus + this.v_amount + this.v_moneytype + str).ToUpper();
        if (str2 == this.v_md5str)
        {
            this.log("校验成功" + str2 + "\r\n");
            if (this.v_pstatus.Equals("20") && ((((this.v_oid != null) && (this.v_amount != null)) && (this.v_oid != "")) && (this.v_amount != "")))
            {
                Maticsoft.BLL.Order.Updateorder(this.v_oid, this.v_amount, "chinabank");
                base.Response.Redirect(base.WWWprefix + "order/success.aspx?id=" + this.v_oid);
            }
        }
        else
        {
            this.log("校验失败" + str2 + "\r\n");
            base.Response.Redirect(base.WWWprefix + "order/success.aspx");
        }
    }

}